package com.hutao.medical.common.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

public class JdbcConnectionTool {
	private static Properties pro = PropsUtil.loadProps("application-dev.properties");
	
	static{
		try {
			Class.forName(pro.getProperty("jdbc.driverClassName"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static Connection getConnection() {
		
		
		String url = pro.getProperty("jdbc.url");
		String username = pro.getProperty("jdbc.username");
		String password = pro.getProperty("jdbc.password");
		Connection conn = null;
		
		try {
			conn = DriverManager.getConnection(url, username, password);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
	
	public static void close(ResultSet rs, Statement stm, Connection conn) {
		try {
			if(rs != null) {
				rs.close();
			}
			
			if(stm != null) {
				stm.close();
			}
			
			if(conn != null) {
				conn.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	
}
